package com.cn.game.service.action;

import com.cn.game.service.dto.HelloReq;
import com.cn.game.service.router.GameCmd;
import com.iohao.game.action.skeleton.annotation.ActionController;
import com.iohao.game.action.skeleton.annotation.ActionMethod;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.stream.IntStream;

/**
 * @author: ZhangZengZeng
 * @date: 2023/7/7 15:01
 */
@ActionController(GameCmd.cmd)
@Slf4j
public class GameAction {


    @ActionMethod(GameCmd.word)
    public HelloReq here(HelloReq helloReq) {
        HelloReq newHelloReq = new HelloReq();
        newHelloReq.name = helloReq.name + ", I'm here ";
        return newHelloReq;
    }
    @ActionMethod(GameCmd.hello)
    public List<HelloReq> list() {
        // 得到一个 List 列表数据，并返回给请求端
        return IntStream.range(1, 5).mapToObj(id -> {
            HelloReq helloReq = new HelloReq();
            helloReq.name = "data:" + id;
            return helloReq;
        }).toList();
    }

}
